package date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author LIBOFEI
 * @ClassName StartEnd
 * @description
 * @date 2021/7/18 17:00
 * @Version 1.0
 **/
public class StartEnd {

    public static void main(String[] args) throws ParseException {

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date startTime = sdf.parse("2019-01-03");
        Date endTime = sdf.parse("2021-09-13");

        Calendar cal = Calendar.getInstance();
        cal.setTime(startTime);
        int startYear = cal.get(Calendar.YEAR);
        int startMonth = cal.get(Calendar.MONTH) + 1;
        int startDay = cal.get(Calendar.DAY_OF_MONTH);


        Calendar cal2 = Calendar.getInstance();
        cal2.setTime(endTime);
        int endYear = cal2.get(Calendar.YEAR);
        int endMonth = cal2.get(Calendar.MONTH) + 1;
        int endDay = cal2.get(Calendar.DAY_OF_MONTH);

        Calendar cal3 = Calendar.getInstance();
        int i = 0;
        for(int year = startYear ; year <= endYear ; year ++){
            i ++;
            cal3.set(Calendar.YEAR,year);
            String yearStr = year + "";
            int end = 12;
            if(year == endYear){
                end = endMonth;
            }
            int s = 1;
            if(i == 1){
                s = startMonth;
            }
            int m = 0;
            for(int month = s ; month <= end; month ++ ){
                m ++;
                String monthStr = month + "";
                if(month < 10){
                    monthStr = "0" + monthStr;
                }
                cal3.set(Calendar.MONTH,month - 1);
                int minDay = cal3.getActualMinimum(cal3.DAY_OF_MONTH);
                int maxDay = cal3.getActualMaximum(cal3.DAY_OF_MONTH);
                int k = minDay;
                if(m == 1){
                    k = startDay;
                }
                int j = maxDay;
                if(year == endYear && month == endMonth){
                    j = endDay;
                }
                for(int day = k; day <= j  ; day ++ ){
                    String dayStr = day + "";
                    if(day < 10){
                        dayStr = "0" + day;
                    }
                    System.out.println(yearStr + "-" + monthStr + "-" + dayStr);
                }
            }
        }
    }
}
